/** 路由文件 */
import React from "react";
import { HashRouter as Router, Route, Routes, Navigate } from "react-router-dom";
import Home from "../components/Home";
import About from "../components/About";
import Layout from "../container/Layout";
import Login from "../container/LoginPage";
import Product from "../components/Product";
import ProductForm from "../components/Product/components/ProductForm";
import News from "../container/News";
import Publications from "../container/Publications";
import NewsForm from "../container/NewsForm";
import Editor from "../container/Editor";
import EditorContent from "../components/EditorContent";
import EditorForm from "../components/EditorForm";
import ArticleDetail from "../container/ArticleDetail";

const AppRouter = () => {
  return (
    <Router>
      <Routes>
        <Route path="/" element={<Navigate to="/home" replace />} />
        <Route path="/" element={<Layout />} >
          <Route index element={<Home />} />
          <Route path="/news" element={<News />} />
          <Route path="/news/detail" element={<ArticleDetail />} />
          <Route path="/about" element={<About />} />
          <Route path="/products" element={<Product />} />
          <Route path="/publications" element={<Publications />} />
          <Route path="/products/edit/:productName" element={<ProductForm />} />
          <Route path="/login" element={<Login mode="LOGIN" />} />
          <Route path="/addNews" element={<NewsForm />} />
          <Route path="/register" element={<Login mode="REGISTER" />} />
          <Route path="*" element={<div>Not Found</div>} />
        </Route>
        <Route path="/editor" element={<Editor />}>
          <Route index element={<EditorContent type="news" />}></Route>
          <Route path="news" element={<EditorContent type="news" />}></Route>
          <Route path="products" element={<EditorContent type="products" />}></Route>
          <Route path="publications" element={<EditorContent type="news" />}></Route>
        </Route>
      </Routes>
    </Router>
  );
};

export default AppRouter;
